local cheak = function(player,requires)
    local list = split_string(requires,',')
    local upgrades = player._upgrades or {}
    if #list==0 then
        table.insert(list,requires)
    end
    for _,name in ipairs(list) do
        if not upgrades[name] then
            return
        end
    end
    return true
end

ac.game:event '玩家-激活科技'(function(_,player,name)
    local upgrades = player._upgrades or {}
    upgrades[name] = true
    player._upgrades = upgrades

    player:notify('玩家-激活科技完毕',player,name)
end)

ac.game:event '单位-添加技能'(function(_,hero,skill)
    local player = hero.owner
    local requires = skill.requires
    if requires then
        if not cheak(player,requires) then
            local list = split_string(requires,',')
            if #list==0 then
                table.insert(list,requires)
            end
            skill.dis_tip = table.concat(list,'|n - ')
            skill:disable()
            player:event '玩家-激活科技完毕'(function(trg,_,name)
                if cheak(player,requires) then
                    trg:remove()
                    skill:enable()
                end
            end)
        end
    end
end)